import { HttpMethod } from '@/services/types';
import { request } from '@/api/request';

/**
 * GET /account 账户列表
 * @param options
 */
export async function resAccount(
  options?: { [key: string]: any },
) {
  return request<API.AccountStruct>('/account', {
    method: HttpMethod.GET,
    ...(options || {}),
  });
}

/**
 * Delete /account/:id 删除账户
 * @param id
 * @param options
 */
export async function resDeleteAccount(
  id: number,
  options?: { [key: string]: any },
) {
  return request<R<null>>('/account' + id, {
    method: HttpMethod.DELETE,
    ...(options || {}),
  });
}

/**
 * POST /account 添加账户
 * @param params
 * @param options
 */
export async function resAddAccount(
  params: API.AccountParams,
  options?: { [key: string]: any },
) {
  return request<R<API.CategoryStruct>>('/account', {
    method: HttpMethod.POST,
    data: params,
    ...(options || {}),
  });
}

/**
 * PUT /account/:id 修改账户
 * @param id
 * @param params
 * @param options
 */
export async function resChangeAccount(
  id: number,
  params: API.AccountParams,
  options?: { [key: string]: any },
) {
  return request<R<null>>('/account/' + id, {
    method: HttpMethod.PUT,
    data: params,
    ...(options || {}),
  });
}

